USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0005_PRIMER_VENC_IMP]    Script Date: 11/28/2011 12:00:41 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0005_PRIMER_VENC_IMP]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0005_PRIMER_VENC_IMP]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0005_PRIMER_VENC_IMP]    Script Date: 11/28/2011 12:00:41 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO



CREATE PROCEDURE [dbo].[WASP_M0005_PRIMER_VENC_IMP]
AS

BEGIN
		SELECT 
		--	Z073B1Cta as cta_emp, 
			Z073B3Cta as cta, 
			Z073B3Oper as oper, 
			Z073B3Suc as suc, 
			min(Z073B3Fpag) fecha_pago,
			max(Z073B3Fpag) ult_fecha

		INTO
			dbo.Prim_cuota_imp 

		FROM  
			z073b3

		WHERE 
			Z073B3Stat = 'S' 

		GROUP BY Z073B3Cta , Z073B3Oper , Z073B3Suc 
END
GO

